.TH qthread_writeEF 3 "APRIL 2011" libqthread "libqthread"
.SH NAME
.BR qthread_writeEF ,
.B qthread_writeEF_const
\- waits for the dest to be empty, then fills it
.SH SYNOPSIS
.B #include <qthread.h>

.I int
.br
.B qthread_writeEF
.RI "(aligned_t * restrict " dest ", const aligned_t * restrict " src );
.PP
.I int
.br
.B qthread_writeEF_const
.RI "(aligned_t *" dest ", aligned_t " src );
.SH DESCRIPTION
These functions wait for memory to become empty, and then fill it. When memory
becomes empty, only one thread blocked like this will be awoken. Data is read
from
.I src
and written to
.IR dest .
.PP
The semantics of writeEF are:
.RS
.PP
1 -
.IR dest 's
FEB state must be "empty"
.br
2 - data is copied from
.I src
to
.I dest
.br
3 -
.IR dest 's
FEB state gets changed from "empty" to "full"
.RE
.SH WARNING
This, and all other FEB-related functions currently operate exclusively on
aligned data. This is to simulate the behavior of the MTA as closely as
possible. If the library was compiled for a 32-bit architecture, it will
require 4-byte alignment and reads/writes will operate on four bytes at a time;
if the library was compiled for a 64-bit architecture, it will require 8-byte
alignment and reads/writes will operate on eight bytes at a time.
.SH RETURN VALUE
On success, the memory address
.I dest
is marked full, the address
.I dest
is filled with the contents of
.I src
and 0 is returned. On error, a non-zero error code is returned.
.SH ERRORS
.TP 12
.B ENOMEM
Not enough memory could be allocated for bookkeeping structures.
.SH SEE ALSO
.BR qthread_empty (3),
.BR qthread_fill (3),
.BR qthread_writeF (3),
.BR qthread_readFF (3),
.BR qthread_readFE (3),
.BR qthread_lock (3),
.BR qthread_unlock (3)
